package com.lxw.study.behavioral.status;

import javax.annotation.Resource;
import java.util.Map;

public class ElevatorContext {
    @Resource
    private Map<String, ElevatorState> stateMap;
    ElevatorState currentState;

    // 初始化为关门状态
    public ElevatorContext() {
        currentState = stateMap.get("closeDoorState");
    }

    public void openDoor() {
        currentState = stateMap.get("openDoorState");
    }

    public void closeDoor() {
        currentState = stateMap.get("closeDoorState");
    }

    public void moveUp() {
        currentState.moveUp();
    }

    public void moveDown() {
        currentState.moveDown();
    }
}
